package com.qj.yantaishan.controller;

import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.qj.yantaishan.common.annotation.Log;
import com.qj.yantaishan.common.enums.BusinessType;
import com.qj.yantaishan.domain.StorePhysicalUser;
import com.qj.yantaishan.service.IStorePhysicalUserService;
import com.qj.yantaishan.common.core.controller.BaseController;
import com.qj.yantaishan.common.core.domain.AjaxResult;
import com.qj.yantaishan.common.utils.poi.ExcelUtil;
import com.qj.yantaishan.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author qihe
 * @date 2022-07-22
 */
@RestController
@RequestMapping("/yantaishan/StorePhysicalUser")
public class StorePhysicalUserController extends BaseController
{
    private String prefix = "yantaishan/StorePhysicalUser";

    @Autowired
    private IStorePhysicalUserService storePhysicalUserService;

    @RequiresPermissions("yantaishan:user:view")
    @GetMapping()
    public String user()
    {
        return prefix + "/user";
    }

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("yantaishan:user:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(StorePhysicalUser storePhysicalUser)
    {
        startPage();
        List<StorePhysicalUser> list = storePhysicalUserService.selectStorePhysicalUserList(storePhysicalUser);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("yantaishan:user:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(StorePhysicalUser storePhysicalUser)
    {
        List<StorePhysicalUser> list = storePhysicalUserService.selectStorePhysicalUserList(storePhysicalUser);
        ExcelUtil<StorePhysicalUser> util = new ExcelUtil<StorePhysicalUser>(StorePhysicalUser.class);
        return util.exportExcel(list, "【请填写功能名称】数据");
    }

    /**
     * 新增【请填写功能名称】
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存【请填写功能名称】
     */
    @RequiresPermissions("yantaishan:user:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(StorePhysicalUser storePhysicalUser)
    {
        return toAjax(storePhysicalUserService.insertStorePhysicalUser(storePhysicalUser));
    }

    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("yantaishan:user:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        StorePhysicalUser storePhysicalUser = storePhysicalUserService.selectStorePhysicalUserById(id);
        mmap.put("storePhysicalUser", storePhysicalUser);
        return prefix + "/edit";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("yantaishan:user:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(StorePhysicalUser storePhysicalUser)
    {
        return toAjax(storePhysicalUserService.updateStorePhysicalUser(storePhysicalUser));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("yantaishan:user:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(storePhysicalUserService.deleteStorePhysicalUserByIds(ids));
    }
}
